<template>
  <div class="noticeAll">
    <a-row :gutter="24">
      <a-col :lg="24" :md="24" :sm="24">
        <a-card :bordered="false" title="公告列表">
          <a-list
            size="large"
            rowKey="id"
            :loading="loading"
            itemLayout="vertical"
            :dataSource="data"
          >
            <a-list-item :key="item.not_id" slot="renderItem" slot-scope="item">
              <a-list-item-meta>
                <div slot="title">
                  <div style="display: flex;justify-content: space-between;align-items: center;">
                    <span>{{ item.not_title }}</span>
                    <!-- <a-icon style="color:rgb(189, 188, 188)" type="delete" @click="del(item.not_id)" /> -->
                  </div>
                </div>
                <template slot="description">
                  <div style="height:50px">{{ item.not_msg }}</div>
                </template>
              </a-list-item-meta>
              <div>{{ item.not_time }}</div>
            </a-list-item>
          </a-list>
        </a-card>
      </a-col>
    </a-row>

  </div>
</template>

<script>
import { getAllNotice } from '@/api/user/notice'
import { TagSelect, StandardFormRow, ArticleListContent } from '@/components'
const TagSelectOption = TagSelect.Option

export default {
  components: {
    TagSelect,
    TagSelectOption,
    StandardFormRow,
    ArticleListContent
  },
  name: 'NoticeAll',
  data () {
    return {
      confirmLoading: false,
      visible: false,
      selectedRowKeys: [],
      loading: false,
      skeLoading: true,
      noticeTitle: '',
      noticeDetail: '',
      loadingMore: false,
      data: [
        // {
        //   not_id: 2,
        //   star: 120, // 点赞
        //   like: 321, // 收藏
        //   message: 222, // 评论
        //   not_title: 'title', // 文章标题
        //   avatar: '', // 头像
        //   href: '发布地址', // 发布地址
        //   not_time: '2016-0-5',
        //   owner: '发布用户', // 发布用户
        //   not_msg: '文章详情'// 文章详情
        // }
      ],
      form: this.$form.createForm(this)
    }
  },

  computed: {
    hasSelected () {
      return this.selectedRowKeys.length > 0
    }
  },
  created () {
    this.getAllNotice()
  },
  mounted () {
    // this.getList()
  },
  methods: {
    change (affixed) {
      // console.log(affixed)
    },
    handleOk (e) {
      this.confirmLoading = true
      if (this.noticeTitle !== '') {
        if (this.noticeDetail !== '') {
          // console.log('00')
          this.visible = false
          this.confirmLoading = false
          this.getAddNotice(this.noticeTitle, this.noticeDetail)
        }
      } else {
        this.$message.info('请填写公告标题或详情!')
        this.visible = false
        this.confirmLoading = false
      }
      // setTimeout(() => {
      // }, 2000)
    },
    handleCancel (e) {
      // console.log('Clicked cancel button')
      this.visible = false
    },
    doAdd () {
      this.visible = true
      this.noticeTitle = ''
      this.noticeDetail = ''
    },

    del (val) {
      var that = this
      this.$confirm({
        title: '确定删除吗?',
        content: '',
        okText: '删除',
        okType: 'danger',
        cancelText: '取消',
        onOk () {
          that.delNotice(val)
          // console.log('OK', val)
        },
        onCancel () {
          console.log('Cancel')
          that.$message.info('取消删除!')
        }
      })
    },

    iptChange (e) {
      // console.log('this.noticeTitle', this.noticeTitle)
      // console.log('ipt', e.target.value)
      //   this.noticeTitle = val
    },
    textChange (e) {
      // console.log(e.target.value)
      //   this.noticeDetail = val
    },
    loadMore () {},
    handleChange (value) {
      // console.log(`selected ${value}`)
    },
    setOwner () {
      const {
        form: { setFieldsValue }
      } = this
      setFieldsValue({
        owner: ['wzj']
      })
    },
    getAllNotice () {
      this.loading = true
      getAllNotice({})
        .then(res => {
          this.skeLoading = false
          // console.log('全部公告列表', res.request)
          this.data = res.result.map(function (obj) {
            var rObj = {}
            rObj.not_id = obj.not_id
            rObj.not_title = obj.not_title
            rObj.not_time = obj.not_time
            rObj.not_msg = obj.not_msg
            rObj.not_bra_id = obj.not_bra_id
            return rObj
          })
          this.loading = false
          // console.log(this.data)
        })
        .catch(err => {
          this.skeLoading = false
          this.loading = false
          console.log(err)
        })
    }
  }
}
</script>
<style lang="less">

// p{
//   color:rgb(189, 188, 188)
// }
</style>
